package se.webbzon.boltzmann.battle.battleaction.punch;

import javax.vecmath.Point3d;

import se.webbzon.boltzmann.battle.object.npc.BattleNPC;
import se.webbzon.boltzmann.game.npc.WalkingDuty;

public class PunchActionDuty extends WalkingDuty {
	
	// Whatever the punch is complete or not
	private boolean hasPunched;
	
	// The action associated with this duty
	private final PunchAction action;
	
	/*============================================================
	Constructors
	============================================================*/

	/** Creates a new punch action duty. **/
	public PunchActionDuty(BattleNPC npc, PunchAction action) {
		super(npc);
		this.action = action;
		hasPunched = false;
	}
	
	/*============================================================
	Public Methods
	============================================================*/
	
	@Override public void onReachTarget() {
		if (!hasPunched) {
			final Point3d origin = new Point3d();
			getOrigin(origin);
			setTarget(origin.x,origin.z,getNPC().getRunSpeed());
			hasPunched = true;
			
			for (BattleNPC target : action.getTargets())
				action.damage(target,3);
		} else
			action.end();
	}

}
